package www.wen.com.common.lib.base.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.databinding.ViewDataBinding
import www.wen.com.common.R
import www.wen.com.common.lib.data.entities.WebEntity
import www.wen.com.common.lib.helper.loading.KeyHelper.WEB_PARAMETER


/**
 * @author WEN
 * @Description:
 * @date 2020/11/25 17:49
 */
abstract class BaseWebFragment<K : ViewDataBinding> : BaseVMFragment<K>() {

    lateinit var mWebView: WebView

    open lateinit var mWebEntity: WebEntity

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        mWebEntity =  requireArguments().getParcelable(WEB_PARAMETER)!!
        return super.onCreateView(inflater, container, savedInstanceState)
    }

    override fun lazyInitView() {
        mWebView = dataBinding.root.findViewById(R.id.webView)
        mWebView.webChromeClient = WebChromeClient()
        mWebView.webViewClient = WebViewClient()
        mWebView.loadUrl(mWebEntity.url)
    }



}